<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <meta name="renderer" content="webkit" />
    <meta name="author" content="中文Lee 360811363@qq.com">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="stylesheet" href="../../../lib/layui-v2.6.3/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../../css/public.css" media="all" />
    <!--
    * [LupMisNotAllowedSync]
    * 本代码为系统自动生成代码，请根据自己业务进行修改;
    * 生成时间 2022-02-15 18:29:17;
    * 版权所有 2020-2022 lizhongwen，并保留所有权利;
    * 说明: 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；不允许对程序代码以任何形式任何目的的再发布;
    * 作者: 中文Lee;
    * 作者主页: http://www.lizhongwen.com;
    * 邮箱: 360811363@qq.com;
    * QQ: 360811363;
    -->
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div id="form-list">
                <form class="layui-form" action="">
                    <input type="hidden" name="ids" id="ids" value="0">
                    <div class="layui-tab-item layui-show" style="padding: 10px;">
                        <div class="layui-form-item">
                            <label class="layui-form-label"></label>
                            <div class="layui-input-block">
                                <b style="color: red;">温馨提示：请谨慎操作，替换之前请备份数据库！！！</b>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">原文件路径</label>
                            <div class="layui-input-block">
                                <input type="text" name="ori_path" value="" lay-verify="required" lay-reqtext="请输入原文件路径" placeholder="请输入原文件路径" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">要替换的路径</label>
                            <div class="layui-input-block">
                                <input type="text" name="new_path" value="" lay-verify="required" lay-reqtext="请输入要替换的路径" placeholder="请输入要替换的路径" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="form-submit">立即替換</button>
                            </div>
                        </div>

                        <div>
                            <table class="layui-hide" id="data-list" lay-filter="data-list"></table>
                        </div>
                    </div>



                </form>
            </div>
        </div>
    </div>
    <script src="../../../js/run.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script type="text/javascript">
        $init(function() {
            var gateway = getQueryString("gateway");
            var ids = getQueryString("ids");
            $("#ids").val(ids);

            selfFrameSubmit(base_gateway + gateway, true, function(ret) {
                if (ret.code == 200) {
                    layer.alert(ret.msg, function() {
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    });
                }
            });
        });
        //统一提交方法
        function selfFrameSubmit(url, isReloadTableList = true, callback = false, dataJson = false) {
            var index = parent.layer.getFrameIndex(window.name);
            form.verify({
                otherReq: function(value, item) {
                    var $ = layui.$;
                    var verifyName = $(item).attr('name'),
                        verifyType = $(item).attr('type'),
                        formElem = $(item).parents('.layui-form'), //获取当前所在的form元素，如果存在的话
                        layReqtext = $(item).attr("layReqtext") || "必填项不能为空",
                        verifyElem = formElem.find('input[name=' + verifyName + ']'), //获取需要校验的元素

                        isTrue = verifyElem.is(':checked'), //是否命中校验

                        focusElem = verifyElem.next().find('i.layui-icon'); //焦点元素
                    //alert(verifyName);
                    if (!isTrue || !value) {
                        //定位焦点
                        focusElem.css(verifyType == 'radio' ? {
                            "color": "#FF5722"
                        } : {
                            "border-color": "#FF5722"
                        });
                        //对非输入框设置焦点
                        focusElem.first().attr("tabIndex", "1").css("outline", "0").blur(function() {
                            focusElem.css(verifyType == 'radio' ? {
                                "color": ""
                            } : {
                                "border-color": ""
                            });
                        }).focus();
                        return layReqtext;
                    }
                }
            });
            //监听提交
            layui.form.on('submit(form-submit)', function(data) {
                var btn = layui.jquery(this);
                if (btn.hasClass("layui-btn-disabled")) {
                    layer.msg('数据传输中，请勿重复提交...', {
                        shade: [0.1, '#393D49'],
                        time: 2000
                    });
                    return false;
                }
                // return false;
                btn.addClass('layui-btn-disabled');
                var loading = layer.load(2, {
                    shade: [0.1, '#393D49'],
                });
                layer.msg('正在提交数据...', {
                    shade: [0.1, '#393D49'],
                    time: 2000
                });
                if (dataJson) {
                    var requestData = dataJson;
                } else {
                    var requestData = data.field;
                }
                request(url, data.field, function(ret) {
                    var code = ret.code;
                    // layer.close(loading);
                    layer.closeAll('loading');
                    setTimeout(function() {
                        btn.removeClass('layui-btn-disabled');
                    }, 1500);
                    if (code == 200) {

                        if (callback) {
                            callback(ret);
                        }
                        // if (isReloadTableList) {
                        //     parent.layui.table.reload('data-list');
                        // }
                        // layer.msg(ret.msg, {
                        //     shade: [0.1, '#393D49'],
                        //     time: 2000,
                        //     icon: 6
                        // });
                    } else {
                        layer.msg(ret.msg, {
                            shade: [0.1, '#393D49'],
                            time: 2000,
                            icon: 5
                        });
                    }
                });
                return false;
            });
        }
    </script>
</body>

</html>